using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Policy;
using UnityEngine;

[Serializable]
[PlayerStateScript(EPlayerState.Idle)]
public class PlayerIdleState : PlayerStateBase
{
    private static readonly int IsWalking = Animator.StringToHash("isWalking");


    public override void FixedUpdate()
    {
        if(!stateMachine.IsTouchingGround)
            stateMachine.SetState(EPlayerState.Fall);
    }

    public PlayerIdleState(PlayerStateMachine sm) : base(sm) { }

    public override void EnterState()
    {
        // Debug.Log("Enter Idle");
        stateMachine.playerComponentContex.animator.SetBool(IsWalking,false);
        
    }

    public override void ExitState()
    {
        // Debug.Log("Exit Idle");
    }

    public override void HandleInput(EPlayerInput playerInput, EInputType inputType)
    {
        switch (playerInput)
        {
            case EPlayerInput.Move:
                if(inputType != EInputType.End)
                    stateMachine.SetState(EPlayerState.Walk);
                break;
            
            case EPlayerInput.Jump:
                if(inputType == EInputType.Begin)
                    stateMachine.SetState(EPlayerState.Jump);
                break;
            
            case EPlayerInput.Throw:
                if (inputType == EInputType.Begin && PlayerAttribute.Instance.hasArrow)
                    stateMachine.SetState(EPlayerState.Throw);
                break;
        }
        
    }
    
}
